From: Colin Walters Date: Mon, 21 Jul 2025 20:36:50 +0000 (-0400) Subject: tests: Add a test case for etc.transient X-Git-Tag: archive/raspbian/2025.7-2+rpi1^2^2~6^2~2^2~10^2 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=fcfa641879b2e84208f675ca6c7d041cfeee3727;p=ostree.git tests: Add a test case for etc.transient This would have caught https://github.com/ostreedev/ostree/issues/3476 --- diff --git a/Justfile b/Justfile index 6232ba1d..2456c2b6 100644 --- a/Justfile +++ b/Justfile @@ -14,7 +14,7 @@ build-noinitramfs *ARGS: # We need a filesystem that supports O_TMPFILE right now (i.e. not overlayfs) # or ostree hard crashes in the http code =/ -unittest_args := "--pids-limit=-1 --tmpfs /var/tmp --tmpfs /tmp" +unittest_args := "--pids-limit=-1 --tmpfs /run --tmpfs /var/tmp --tmpfs /tmp" # Build and then run unit tests. If this fails, it will try to print # the errors to stderr. However, the full unabridged test log can diff --git a/tests-unit-container/test-prepare-root.sh b/tests-unit-container/test-prepare-root.sh index 441246e2..466139a0 100755 --- a/tests-unit-container/test-prepare-root.sh +++ b/tests-unit-container/test-prepare-root.sh @@ -9,9 +9,11 @@ set -xeuo pipefail test "${TEST_CONTAINER}" = 1 cleanup() { - if mountpoint /target-sysroot &>/dev/null; then - umount -lR /target-sysroot - fi + for mnt in /target-sysroot /sysroot.tmp; do + if mountpoint "$mnt" &>/dev/null; then + umount -lR "$mnt" + fi + done rm -rf /run/ostree-booted /run/ostree } trap cleanup EXIT @@ -21,11 +23,17 @@ test '!' -f /run/ostree-booted mkdir /target-sysroot # Needs to be a mount point mount --bind /target-sysroot /target-sysroot + ostree admin init-fs --epoch=1 /target-sysroot cd /target-sysroot ostree admin --sysroot=. stateroot-init default # now we just fake out a deployment -mkdir -p ostree/deploy/default/deploy/1234/{etc,usr,sysroot} +mkdir -p ostree/deploy/default/deploy/1234/{etc,usr/etc,usr/bin,sysroot} +# Populate some data +(cd ostree/deploy/default/deploy/1234 + echo passwd > usr/etc/passwd + echo bash > usr/bin/bash +) ln -sr ostree/deploy/default/deploy/1234 boot/ostree.0 t=$(mktemp) @@ -45,6 +53,8 @@ test -f /run/ostree-booted for d in etc usr; do mountpoint /target-sysroot/${d} done +# Not transient by default +test $(findmnt -no FSTYPE /target-sysroot/etc) '!=' tmpfs # Default is ro in our images grep -q 'readonly.*true' /usr/lib/ostree/prepare-root.conf @@ -53,6 +63,7 @@ grep -q 'readonly.*true' /usr/lib/ostree/prepare-root.conf cleanup test '!' -f /run/ostree-booted +# Test with the default config mv /usr/lib/ostree/prepare-root.conf{,.orig} mount --bind /target-sysroot /target-sysroot @@ -60,4 +71,28 @@ mount --bind /target-sysroot /target-sysroot findmnt -R /target-sysroot [[ "$(findmnt -n -o OPTIONS /target-sysroot/sysroot)" == *rw* ]] +# Reset the config to what's in the image +mv /usr/lib/ostree/prepare-root.conf{.orig,} + +cleanup + echo "ok verified default prepare-root" + +cp /usr/lib/ostree/prepare-root.conf{,.orig} +cat <>/usr/lib/ostree/prepare-root.conf +[etc] +transient = true +EOF + +mount --bind /target-sysroot /target-sysroot +/usr/lib/ostree/ostree-prepare-root /target-sysroot + +# Verify we have a tmpfs upper for etc +etc_options=$(findmnt -no OPTIONS /target-sysroot/etc) +[[ $etc_options =~ "upperdir=/run/ostree/transient-etc" ]] + +# Reset the config +mv /usr/lib/ostree/prepare-root.conf{.orig,} +cleanup + +echo "ok verified etc.transient"